package com.sky.controller.user;
import com.sky.dto.MeetingRoomQueryDTO;
import com.sky.entity.MeetingRoom;
import com.sky.result.Result;
import com.sky.service.MeetingRoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin
@RestController("userMeetingRoomController")
@RequestMapping("/user/meetingRoom")
@Slf4j
@Api(tags="首页会议室信息查询接口")
public class MeetingRoomController {
    @Autowired
    private MeetingRoomService meetingRoomService;
    /**
     */
    @ApiOperation(value="查询所有会议室")
    @GetMapping("/")
    public Result<List<MeetingRoom>> getAllMeetingRooms(){   //由于get请求方式不是json 格式，所以不用ResquestBody
        log.info("查询所有的会议室");                 //框架会自动将数据封装到实体类对象中，即使有一些为空
        List<MeetingRoom> meetingRooms = meetingRoomService.findAll();
        return Result.success(meetingRooms);
    }
    //根据条件查询会议室

    /**
     * 筛选会议室
     * @param
     * @return
     */
    @ApiOperation(value = "根据条件查询会议室")
    @PostMapping("/query")
    public Result<List<MeetingRoom>> queryMeetingRooms(@RequestBody MeetingRoomQueryDTO query) {
        System.out.println("根据条件查询会议室：" + query);
        List<MeetingRoom> meetingRooms = meetingRoomService.queryByConditions(query);
        return Result.success(meetingRooms);
    }

}